<template>
  <div>
    <InnerPageTable ref="appTable" :config="tableConfig"></InnerPageTable>
  </div>
</template>
<script>
import { innerAppColumns } from "./columns.js";
import appAssignUserAPI from "@/api/appAssignUserAPI.js";
import locales from "./locales.js";
import { CoreModuleName } from "@/const";

export default {
  name: "inner-app-list",
  mixins: [locales],
  props: {},
  data() {
    return {
      currentUserInfo: {},
      formOrg: {
        tenantCode: "",
        category: ""
      },
      tableData: []
    };
  },
  computed: {
    tableConfig() {
      return {
        resource: this.tableData,
        columnsFn: innerAppColumns.bind(this),
        isPage: false,
        autoFirst: false,
        rowClickHandle: this.onRowClick,
        highlightRow: true,
        rowClassNameFn: this.rowClassName // 自定义行样式
      };
    }
  },
  created() {
    // 当前登录用户
    const RIPPLES = "ripples";
    this.currentUserInfo = $store.state[CoreModuleName].userInfo;
    this.formOrg.tenantCode = this.currentUserInfo.tenantCode;
    this.formOrg.category = this.currentUserInfo.category;
  },
  mounted() {
    this.search();
  },
  methods: {
    // 自定义行样式
    rowClassName(row) {
      // enabled:1-有效；0-无效
      if (row.enabled == 0) {
        return "tableDisableStyle";
      }
    },
    search() {
      appAssignUserAPI.queryAppList(this.formOrg).then(data => {
        this.tableData = data;
      });
    },
    onRowClick(row) {
      this.$emit("click", row);
    }
  },
  watch: {},
  directives: {}
};
</script>
<style lang="less"></style>
